// The AppStateManager inherits from the class AppStateListener and mainly
// implements its abstract methods. It also contains:
// std::vector for all existing states (m_States)
// std::vector for the stack of the above states currently in use (m_ActiveStateStack)

#ifndef APP_STATE_MANAGER_HPP
#define APP_STATE_MANAGER_HPP

#include "AppState.hpp"

class AppStateManager : public AppStateListener
{
	public:

		// Create the "state_info" struct.
		typedef struct
		{
			Ogre::String name;
			AppState* state;
		} state_info;

		// Constructor/Destructor
		AppStateManager();
		~AppStateManager();

		// Inherit all the AppStateListener functions.
		void manageAppState(Ogre::String stateName, AppState* state);

		AppState* findByName(Ogre::String stateName);

		void start(AppState* state);
		void changeAppState(AppState* state);
		bool pushAppState(AppState* state);
		void popAppState();
		void pauseAppState();
		void shutdown();
		void popAllAndPushAppState(AppState* state);

	protected:

		// Initial state of the manager.
		void init(AppState *state);

		// Create the vectors for the state stacks.
		std::vector<AppState*>		m_ActiveStateStack;
		std::vector<state_info>		m_States;

		// When true, shuts down the stackmanager, and consequently the program.
		bool						m_bShutdown;
};

#endif